<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>四川大学基线平台</title>
    <link rel="stylesheet" href="layui/css/layui.css">
</head>
<body>
<div class="layui-layout layui-layout-admin">
    <div class="layui-header">
        <div class="layui-logo layui-hide-xs layui-bg-black">四川大学基线平台</div>
        <!-- 头部区域（可配合layui 已有的水平导航） -->
        <ul class="layui-nav layui-layout-left">
            <!-- 移动端显示 -->
            <li class="layui-nav-item layui-show-xs-inline-block layui-hide-sm" lay-header-event="menuLeft">
                <i class="layui-icon layui-icon-spread-left"></i>
            </li>
            <li class="layui-nav-item layui-hide-xs"><a href="index.html">回到首页</a></li>
            <!--      <li class="layui-nav-item layui-hide-xs"><a href="">分布式系统</a></li>-->
            <!--      <li class="layui-nav-item layui-hide-xs"><a href="">扩展式系统</a></li>-->
            <!--      <li class="layui-nav-item layui-hide-xs"><a href="">备份系统</a></li>-->
            <li class="layui-nav-item">
                <!--        <a href="javascript:;">日志管理</a>-->
                <dl class="layui-nav-child">
                    <dd><a href="">日志系统1</a></dd>
                    <dd><a href="">日志系统2</a></dd>
                    <dd><a href="">日志系统3</a></dd>
                </dl>
            </li>
        </ul>
        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item layui-hide layui-show-md-inline-block">
                <a href="javascript:;">
                    <img src="//tva1.sinaimg.cn/crop.0.0.118.118.180/5db11ff4gw1e77d3nqrv8j203b03cweg.jpg"
                         class="layui-nav-img">
                    tester
                </a>
                <dl class="layui-nav-child">
                    <dd><a href="">Your Profile</a></dd>
                    <dd><a href="">Settings</a></dd>
                    <dd><a href="/logout">Sign out</a></dd>
                </dl>
            </li>
            <li class="layui-nav-item" lay-header-event="menuRight" lay-unselect>
                <a href="javascript:;">
                    <i class="layui-icon layui-icon-more-vertical"></i>
                </a>
            </li>
        </ul>
    </div>

    <div class="layui-side layui-bg-black">
        <div class="layui-side-scroll">
            <!-- 左侧导航区域（可配合layui已有的垂直导航） -->
            <ul class="layui-nav layui-nav-tree" lay-filter="test">
                <li class="layui-nav-item layui-nav-itemed">
                    <a class="" href="javascript:;">基础管理</a>
                    <dl class="layui-nav-child">
                        <dd><a href="user.html">用户管理</a></dd>
                    </dl>
                </li>
                <li class="layui-nav-item layui-nav-itemed">
                    <a href="javascript:;">设备管理</a>
                    <dl class="layui-nav-child">
                        <dd><a href="device.html">设备列表</a></dd>
                        <dd><a href="scanData.html">扫描数据列表</a></dd>
                    </dl>
                </li>
                <li class="layui-nav-item layui-nav-itemed">
                    <a href="javascript:;">系统统计</a>
                    <dl class="layui-nav-child">
                        <dd><a href="policyCount.html">安全策略统计</a></dd>
                        <!--                        <dd><a href="policyDetial.html">安全策略详情</a></dd>-->
                    </dl>
                </li>
                <li class="layui-nav-item layui-nav-itemed">
                    <a href="index_user.html">客户端下载</a>
                </li>

            </ul>
        </div>
    </div>

    <div class="layui-body">
        <!-- 内容主体区域 -->

        <div style="padding: 15px;">
          <span class="layui-breadcrumb">
            <a href="index.html">首页</a>
            <a><site>设备管理</site></a>
            <a><site>扫描数据列表</site></a>
            <a><site>详情</site></a>
          </span>

            <hr class="layui-bg-blue">
            <div id="view"></div>


        </div>
        <div id="container" style="height: 500px"></div>
    </div>

    <script src="layui/layui.js" charset="utf-8"></script>
    <script src="jquery/jquery-3.6.0.js" charset="utf-8"></script>

    <script type="text/html" id="toolbarDemo">
        <div class="layui-btn-container">
        </div>
    </script>

    <script type="text/html" id="barDemo">
        <!--  <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>-->
        <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
    </script>

    <script type="text/html" id="domeFirst">
        <div style="height: 500px">
            <fieldset class="layui-elem-field">
                <legend>主机名</legend>
                <div class="layui-field-box">
                    {{ d.hostname }}
                </div>
            </fieldset>
            <fieldset class="layui-elem-field">
                <legend>操作系统信息</legend>
                <div class="layui-field-box">
                    {{ d.osInfo }}
                </div>
            </fieldset>
            <fieldset class="layui-elem-field">
                <legend>CPU信息</legend>
                <div class="layui-field-box">
                    {{ d.cpuInfo }}
                </div>
            </fieldset>
            <fieldset class="layui-elem-field">
                <legend>主板ID</legend>
                <div class="layui-field-box">
                    {{ d.basename }}
                </div>
            </fieldset>
            <fieldset class="layui-elem-field">
                <legend>IP地址</legend>
                <div class="layui-field-box">
                    {{ d.ip }}
                </div>
            </fieldset>
            <fieldset class="layui-elem-field">
                <legend>开放端口</legend>
                <div class="layui-field-box">
                    {{ d.openPort }}
                </div>
            </fieldset>
            <fieldset class="layui-elem-field">
                <legend>内存使用情况</legend>
                <div class="layui-field-box">
                    {{ d.usedMemory }}
                </div>
            </fieldset>
            <fieldset class="layui-elem-field">
                <legend>更新时间</legend>
                <div class="layui-field-box">
                    {{ d.registerTime }}
                </div>
            </fieldset>
        </div>
    </script>

    <script>
        // 获取后端数据
        function getBaseData() {

            // 获取路由跳转参数
            function GetUrlParam(name) {
                var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
                var r = window.location.search.substr(1).match(reg);
                if (r != null) return unescape(r[2]);
                return null;
            }

            // 使用获取参数向服务器请求数据
            var basename = GetUrlParam("basename");
            console.log((basename))

            layui.use('table', function () {
                $.ajax({
                    url: '/baseline/selectByBasename',
                    type: 'post',
                    data: {
                        basename: basename
                    }, // 传递给后端的参数
                    datatype: "json",        // 返回类型，text文本、html页面、json数据
                    success: function (response) {
                        console.log("返回: " + response);
                        if (response.code === 200) {
                            var res = response.data

                            var tpl = document.getElementById('domeFirst').innerHTML;
                            var viewTpl = layui.laytpl;
                            viewTpl(tpl).render(res, function (html) {
                                document.getElementById('view').innerHTML = html;
                                console.log(res)
                            });
                        }
                    },
                    error: function (response) {
                        console.log("出错返回: " + response);
                    }
                })
            });
        }

        getBaseData()
    </script>
</div>

</body>
</html>